
<div class="noprint">
	<?php include_partial('globals/backoffice_menu') ?>
</div>
<?php include_component('globals', 'restaurantDropdown', array('html_id' => 'restaurant_select')) ?>
<div class="noprint">
	<?php include_component('globals', 'console') ?>
</div>

<div class="noprint">
	<table>
		<tr>
			<td><a class="reservation_button_week_day noprint"
				href="<?php echo url_for('@reservation_list?date=' . Util::offsetTodayDate(date('Y-m-d'), 0)) ?>">
					<span
					class="ui-button ui-widget ui-state-active ui-corner-all ui-button-text-only yvo-smallbutton ">
						<span class="ui-button-text yvo-smalltext"> <?php echo __('Today') ?><br />
							<?php echo Util::getShortDate(date('Y-m-d')) ?>
					</span>
				</span>
			</a>
			</td>
			<td><a class="reservation_button_week_day noprint"
				href="<?php echo url_for('@reservation_list?date=' . Util::offsetTodayDate(date('Y-m-d'), 1)) ?>">
					<span
					class="ui-button ui-widget ui-state-active ui-corner-all ui-button-text-only yvo-smallbutton ">
						<span class="ui-button-text yvo-smalltext"> <?php echo __('Tomorrow') ?><br />
							<?php echo Util::getShortDate(Util::offsetTodayDate(date('Y-m-d'), 1)) ?>
					</span>
				</span>
			</a>
			</td>
			<td><a class="reservation_button_week_day noprint"
				href="<?php echo url_for('@reservation_list?date=' . Util::offsetTodayDate(date('Y-m-d'), 2)) ?>">
					<span
					class="ui-button ui-widget ui-state-active ui-corner-all ui-button-text-only yvo-smallbutton ">
						<span class="ui-button-text yvo-smalltext"> <?php echo format_date(Util::offsetTodayDate(date('Y-m-d'), 2),'EEEE', 'nl') ?><br />
							<?php echo Util::getShortDate(Util::offsetTodayDate(date('Y-m-d'), 2)) ?>

					</span>
				</span>
			</a>
			</td>
			<td><a class="reservation_button_week_day noprint"
				href="<?php echo url_for('@reservation_list?date=' . Util::offsetTodayDate(date('Y-m-d'), 3)) ?>">
					<span
					class="ui-button ui-widget ui-state-active ui-corner-all ui-button-text-only yvo-smallbutton ">
						<span class="ui-button-text yvo-smalltext"> <?php echo format_date(Util::offsetTodayDate(date('Y-m-d'), 3),'EEEE', 'nl') ?><br />
							<?php echo Util::getShortDate(Util::offsetTodayDate(date('Y-m-d'), 3)) ?>
					</span>
				</span>
			</a>
			</td>
			<td><a class="reservation_button_week_day noprint"
				href="<?php echo url_for('@reservation_list?date=' . Util::offsetTodayDate(date('Y-m-d'), 4)) ?>">
					<span
					class="ui-button ui-widget ui-state-active ui-corner-all ui-button-text-only yvo-smallbutton ">
						<span class="ui-button-text yvo-smalltext"> <?php echo format_date(Util::offsetTodayDate(date('Y-m-d'), 4),'EEEE', 'nl') ?><br />
							<?php echo Util::getShortDate(Util::offsetTodayDate(date('Y-m-d'), 4)) ?>
					</span>
				</span>
			</a>
			</td>
			<td><a class="reservation_button_week_day noprint"
				href="<?php echo url_for('@reservation_list?date=' . Util::offsetTodayDate(date('Y-m-d'), 5)) ?>">
					<span
					class="ui-button ui-widget ui-state-active ui-corner-all ui-button-text-only yvo-smallbutton ">
						<span class="ui-button-text yvo-smalltext"> <?php echo format_date(Util::offsetTodayDate(date('Y-m-d'), 5),'EEEE', 'nl') ?><br />
							<?php echo Util::getShortDate(Util::offsetTodayDate(date('Y-m-d'), 5)) ?>
					</span>
				</span>
			</a>
			</td>
			<td><a class="reservation_button_week_day noprint"
				href="<?php echo url_for('@reservation_list?date=' . Util::offsetTodayDate(date('Y-m-d'), 6)) ?>">
					<span
					class="ui-button ui-widget ui-state-active ui-corner-all ui-button-text-only yvo-smallbutton ">
						<span class="ui-button-text yvo-smalltext"> <?php echo format_date(Util::offsetTodayDate(date('Y-m-d'), 6),'EEEE', 'nl') ?><br />
							<?php echo Util::getShortDate(Util::offsetTodayDate(date('Y-m-d'), 6)) ?>
					</span>
				</span>
			</a>
			</td>
		</tr>
	</table>

	<table class="noprint">
		<tr>
			<td><?php echo __('Date') ?></td>
			<td>
				<form id="reservationListDateForm" class="noprint">
					<input type="text" id="reservation_list_date"
						value="<?php echo Util::convertDateServerClient($sf_request->getParameter('date')) ?>" />
				</form>
			</td>
			<td><?php include_component('globals', 'specialDates') ?>
			</td>
		</tr>
	</table>
</div>
<?php //noprint end ?>
<div
	style="height: 10px; clear: both;"></div>
<div class="ui-widget">
	<div class="ui-widget">
		<div class="ui-state-highlight ui-corner-all yvo-rowday">
			<div>
				<span class="yvo-colday"> <?php echo decideTodayOrTomorrow($sf_params->get('date')) ?>
					<?php echo format_date($sf_params->get('date'), 'D') ?>
				</span> 
				<a class="reservation_button_week_day  noprint" href="#"
					onclick="window.print();"> <span
					class="ui-button ui-widget ui-state-active ui-corner-all ui-button-text-only yvo-smallbutton ">
						<span class="ui-button-text yvo-smalltext"> <?php echo __('Print') ?>
					</span>
				</span>
				</a>
			</div>
		</div>
	</div>
	<div style="height: 2px; clear: both;"></div>

	<?php foreach ($day_intervals as $day_interval): ?>
	<div class="ui-widget">
		<div
			class="ui-widget-header ui-state-active ui-corner-all yvo-intervalheader">
			<span class="yvo-intervalname"><?php echo $day_interval['name'] ?> </span>
			<span class="yvo-intervalstart"><?php echo $day_interval['time_start']?>
			</span> <span class="yvo-intervalend"><?php echo $day_interval['time_end']?>
			</span>
		</div>
	</div>
	<?php   if (!empty($reservations[$day_interval['name']])): ?>
	<?php  foreach ($reservations[$day_interval['name']] as $time => $loc_reservations): ?>
	<?php if (!empty($loc_reservations)): ?>
	<?php $total_persons = 0 ?>
	<div>
		<span class="yvo-rowtime"><?php echo $time ?> </span>

		<div class="noshow" style="font-size: 0.8em">
			<table border="0">
				<tr style="border: 1px solid black;">
				<td width="60">Tijd</td>
				<td width="30">Pax</td>
				<td width="30">Tafel</td>
				<td width="150">Naam gast</td>
				<td width="150">Naam bedrijf</td>
				<td width="150">Opmerkingen</td>
				<td width="100">Telefoonnr</td>
				</tr>
			</table>
		</div>
				
				
				
		<div class="">
			<?php foreach ($loc_reservations as $reservation): ?>
			
			
			<div id="<?php echo $reservation['token'] ?>" class="noprint yvo-clickme yvo-rowreservation ui-widget-content ui-state-focus ui-corner-all">
				<span class="yvo-coltime w40"><?php //echo $reservation['time'] ?> </span>
				<span class="yvo-colpax w40"><?php echo $reservation['person_no'] ?> </span>
				<span class="yvo-coltable w40"> <a
					href="<?php echo url_for('@reservation_backoffice_edit?token=' . $reservation['token']) ?>">
						T:<?php echo $reservation['table_no'] ?>
				</a>
				</span> 
				<span class="yvo-guestisin noprint"> <a href="#"
					onClick="checkGuestIn(<?php echo $reservation['reservation_id'] .",".$reservation['guest_in'] ?>);">
						<?php 
						if (!empty($reservation['guest_in'])){
							echo '<span id="guest_in_button'.$reservation['reservation_id'] .'" class="ui-icon ui-icon-circle-check"/>';
						}else{
							echo '<span id="guest_in_button'.$reservation['reservation_id'] .'" class="ui-icon ui-icon-circle-close"/>';
						}
						?>
				</a>
				</span>
				<span class="yvo-colname w150"> <a
					href="<?php echo url_for('@reservation_backoffice_edit?token=' . $reservation['token']) ?>">
						<?php if ( $reservation['name_first'] ) {
							echo $reservation['name_first'] . ' ';
						}
						?> <?php echo $reservation['name_last'] ?>
				</a>
				</span> 
				<span class="yvo-colcomp w150"> <a
					href="<?php echo url_for('@reservation_backoffice_edit?token=' . $reservation['token']) ?>">
						<?php
						if ( $reservation['name_company'] ) {
							echo $reservation['name_company'];
						} else {
							echo '&nbsp;';
						}
						?>
				</a>
				</span>
				<span class="yvo-colcomm w150"> <?php 
				if ( $reservation['comments_diet'] ) {
					echo strtoupper ( __('diet')) . ': ' . $reservation['comments_diet'];
					if ( $reservation['comments_general'] || $reservation['comments_internal'] ) {
						echo '<br />';
					}
				} else {
					echo '&nbsp;';
				}
				?> <?php
				if ( $reservation['comments_general'] ) {
					echo strtoupper ( __('general')) . ': ' . $reservation['comments_general'] ;
					if ( $reservation['comments_internal'] ) {
						echo '<br />';
					}
				} else {
					echo '&nbsp;';
				}
				?> <?php
				if ( $reservation['comments_internal'] ) {
					echo strtoupper ( __('internal')) . ': ' . $reservation['comments_internal'] . '';
				} else {
					echo '&nbsp;';
				}
				?>
				</span> <span class="yvo-coltel w100"> <?php if ( $reservation['phone'] ) {
					echo $reservation['phone'] . ' ';
				}
				?> <?php echo $reservation['mobile'] ?>
				</span>
			</div>
			
			<div class="noshow" style="font-size: 0.8em">
			
				<table border="0" style="border: 1px solid black;">
					<tr>
						<td width="60">
							<?php echo $reservation['time'] ?>
						</td>
						<td width="30">
							<?php echo $reservation['person_no'] ?>
						</td>
						<td width="30">
							<?php echo $reservation['table_no'] ?>
						</td>
						<td width="150">
							<?php if ( $reservation['name_first'] ) {
								echo $reservation['name_first'] . ' ';
							}
							?> <?php echo $reservation['name_last'] ?>
						</td>
						<td width="150">
							<?php
							if ( $reservation['name_company'] ) {
								echo $reservation['name_company'];
							} else {
								echo '&nbsp;';
							}
							?>
						</td>
						<td width="150">
							<?php
							if ( $reservation['comments_general'] ) {
								echo strtoupper ( __('general')) . ': ' . $reservation['comments_general'] ;
								if ( $reservation['comments_internal'] ) {
									echo '<br />';
								}
							} else {
								echo '&nbsp;';
							}
							?> <?php
							if ( $reservation['comments_internal'] ) {
								echo strtoupper ( __('internal')) . ': ' . $reservation['comments_internal'] . '';
							} else {
								echo '&nbsp;';
							}
							?>
						</td>
						<td width="100">
							<?php if ( $reservation['phone'] ) {
								echo $reservation['phone'] . ' ';
								}
								?> <?php echo $reservation['mobile'] ?>
						</td>
					</tr>
				</table>
			
			</div>
			
			<?php endforeach //end RESERVATIONS IN TIMESLOT ?>

			<div class="noshow" style="font-size: 0.8em">
				<table border="0">
				<tr>
					<td width="60">&nbsp;</td>
					<td width="30">&nbsp;</td>
					<td width="30">&nbsp;</td>
					<td width="150">&nbsp;</td>
					<td width="150">&nbsp;</td>
					<td width="150">&nbsp;</td>
					<td width="100">&nbsp;</td>
				</tr>
				<tr>
					<td width="60">&nbsp;</td>
					<td width="30">&nbsp;</td>
					<td width="30">&nbsp;</td>
					<td width="150">&nbsp;</td>
					<td width="150">&nbsp;</td>
					<td width="150">&nbsp;</td>
					<td width="100">&nbsp;</td>
				</tr>
				<tr>
					<td width="60">&nbsp;</td>
					<td width="30">&nbsp;</td>
					<td width="30">&nbsp;</td>
					<td width="150">&nbsp;</td>
					<td width="150">&nbsp;</td>
					<td width="150">&nbsp;</td>
					<td width="100">&nbsp;</td>
				</tr>
			</table>
			</div>
		</div>
		<?php // end reservations in timeslot div ?>
		
	</div>
	<?php endif // end IF RESERVATION ?>

	<?php endforeach // end ALL RESERVATION ?>
	<?php else: ?>
	<div class="yvo-rowtotalslot">
		<span class="yvo-coltime">&nbsp;</span> <span
			class="yvo-colpax smalltext">0</span>
	</div>
	<?php endif ?>

	<?php endforeach // day_interval?>

	<div style="display: none;">
		To hide from users testing the database

		<h1>This is the original code</h1>


		<div class="noprint">
			<?php include_partial('globals/backoffice_menu') ?>
		</div>
		<?php include_component('globals', 'restaurantDropdown', array('html_id' => 'restaurant_select')) ?>
		<div class="noprint">
			<?php include_component('globals', 'console') ?>
		</div>

		<div class="noprint">
			<table>
				<tr>
					<td><a class="reservation_button_week_day"
						href="<?php echo url_for('@reservation_list?date=' . Util::offsetTodayDate(date('Y-m-d'), 0)) ?>">
							<span
							class="ui-button ui-widget ui-state-active ui-corner-all ui-button-text-only yvo-smallbutton ">
								<span class="ui-button-text yvo-smalltext"> <?php echo __('Today') ?><br />
									<?php echo Util::getShortDate(date('Y-m-d')) ?>
							</span>
						</span>
					</a>
					</td>
					<td><a class="reservation_button_week_day"
						href="<?php echo url_for('@reservation_list?date=' . Util::offsetTodayDate(date('Y-m-d'), 1)) ?>">
							<span
							class="ui-button ui-widget ui-state-active ui-corner-all ui-button-text-only yvo-smallbutton ">
								<span class="ui-button-text yvo-smalltext"> <?php echo __('Tomorrow') ?><br />
									<?php echo Util::getShortDate(Util::offsetTodayDate(date('Y-m-d'), 1)) ?>
							</span>
						</span>
					</a>
					</td>
					<td><a class="reservation_button_week_day"
						href="<?php echo url_for('@reservation_list?date=' . Util::offsetTodayDate(date('Y-m-d'), 2)) ?>">
							<span
							class="ui-button ui-widget ui-state-active ui-corner-all ui-button-text-only yvo-smallbutton ">
								<span class="ui-button-text yvo-smalltext"> <?php echo format_date(Util::offsetTodayDate(date('Y-m-d'), 2),'EEEE', 'nl') ?><br />
									<?php echo Util::getShortDate(Util::offsetTodayDate(date('Y-m-d'), 2)) ?>

							</span>
						</span>
					</a>
					</td>
					<td><a class="reservation_button_week_day"
						href="<?php echo url_for('@reservation_list?date=' . Util::offsetTodayDate(date('Y-m-d'), 3)) ?>">
							<span
							class="ui-button ui-widget ui-state-active ui-corner-all ui-button-text-only yvo-smallbutton ">
								<span class="ui-button-text yvo-smalltext"> <?php echo format_date(Util::offsetTodayDate(date('Y-m-d'), 3),'EEEE', 'nl') ?><br />
									<?php echo Util::getShortDate(Util::offsetTodayDate(date('Y-m-d'), 3)) ?>
							</span>
						</span>
					</a>
					</td>
					<td><a class="reservation_button_week_day"
						href="<?php echo url_for('@reservation_list?date=' . Util::offsetTodayDate(date('Y-m-d'), 4)) ?>">
							<span
							class="ui-button ui-widget ui-state-active ui-corner-all ui-button-text-only yvo-smallbutton ">
								<span class="ui-button-text yvo-smalltext"> <?php echo format_date(Util::offsetTodayDate(date('Y-m-d'), 4),'EEEE', 'nl') ?><br />
									<?php echo Util::getShortDate(Util::offsetTodayDate(date('Y-m-d'), 4)) ?>
							</span>
						</span>
					</a>
					</td>
					<td><a class="reservation_button_week_day"
						href="<?php echo url_for('@reservation_list?date=' . Util::offsetTodayDate(date('Y-m-d'), 5)) ?>">
							<span
							class="ui-button ui-widget ui-state-active ui-corner-all ui-button-text-only yvo-smallbutton ">
								<span class="ui-button-text yvo-smalltext"> <?php echo format_date(Util::offsetTodayDate(date('Y-m-d'), 5),'EEEE', 'nl') ?><br />
									<?php echo Util::getShortDate(Util::offsetTodayDate(date('Y-m-d'), 5)) ?>
							</span>
						</span>
					</a>
					</td>
					<td><a class="reservation_button_week_day"
						href="<?php echo url_for('@reservation_list?date=' . Util::offsetTodayDate(date('Y-m-d'), 6)) ?>">
							<span
							class="ui-button ui-widget ui-state-active ui-corner-all ui-button-text-only yvo-smallbutton ">
								<span class="ui-button-text yvo-smalltext"> <?php echo format_date(Util::offsetTodayDate(date('Y-m-d'), 6),'EEEE', 'nl') ?><br />
									<?php echo Util::getShortDate(Util::offsetTodayDate(date('Y-m-d'), 6)) ?>
							</span>
						</span>
					</a>
					</td>
				</tr>
			</table>

			<table>
				<tr>
					<td><?php echo __('Date') ?></td>
					<td>
						<form id="reservationListDateForm">
							<input type="text" id="reservation_list_date"
								value="<?php echo Util::convertDateServerClient($sf_request->getParameter('date')) ?>" />
						</form>
					</td>
					<td><?php include_component('globals', 'specialDates') ?>
					</td>
				</tr>
			</table>
		</div>
		<?php //noprint end ?>
		<div class="ui-widget">
			<div class="ui-state-highlight ui-corner-all">
				<div class="yvo-indent50">

					<strong><?php echo decideTodayOrTomorrow($sf_params->get('date')) ?>
						<?php echo format_date($sf_params->get('date'), 'D') ?> </strong>
					<?php //echo decideSpecialDate($sf_params->get('date'), $special_dates) ?>
					<a class="reservation_button_week_day" href="#"
						onclick="window.print();"> <span
						class="ui-button ui-widget ui-state-active ui-corner-all ui-button-text-only yvo-smallbutton ">
							<span class="ui-button-text yvo-smalltext"> <?php echo __('Print') ?>
						</span>
					</span>
					</a>
				</div>
			</div>
		</div>


		<table style="border-spacing: 3px; padding: 3px;">
			<?php foreach ($day_intervals as $day_interval): ?>
			<tr>
				<td class="yvo-rowday" colspan="3"><?php echo $day_interval['name'] ?>
					<?php echo $day_interval['time_start']?>-<?php echo $day_interval['time_end']?>
				</td>
			</tr>
			<?php if (!empty($reservations[$day_interval['name']])): ?>
			<?php foreach ($reservations as $interval_name => $reservations_array): ?>
			<?php foreach ($reservations_array as $time => $reservations): ?>
			<?php if (!empty($reservations)): ?>
			<?php $total_persons = 0 ?>
			<tr>
				<td class="yvo-coltime" valign="top"><a href=""> <?php echo $time ?>
				</a>
				</td>
				<td valign="top">
					<table style="padding: 0px; border: 1px; border-collapse: true;">
						<?php foreach ($reservations as $reservation): ?>
						<tr>
							<td class="yvo-colpax"><?php echo $reservation['person_no'] ?>
							</td>
							<td class="yvo-coltable">T:<?php echo $reservation['table_no'] ?>
							</td>
							<td class="yvo-colname"><a
								href="<?php echo url_for('@reservation_backoffice_edit?token=' . $reservation['token']) ?>">
									<?php if ( $reservation['name_first'] ) {
										echo $reservation['name_first'] . ' ';
									}
									?> <?php echo $reservation['name_last'] ?>
							</a>
							</td>
							<td class="yvo-colcomp"><a
								href="<?php echo url_for('@reservation_backoffice_edit?token=' . $reservation['token'])?>">
									<?php
									if ( $reservation['name_company'] ) {
										echo $reservation['name_company'];
									} else {
										echo '&nbsp;';
									}
									?>
							</a>
							</td>
							<td class="yvo-colcomm"><?php 
							if ( $reservation['comments_diet'] ) {
								echo __('diet') . ':' . $reservation['comments_diet'];
								if ( $reservation['comments_general'] || $reservation['comments_internal'] ) {
									echo '<br />';
								}
							} else {
								echo '&nbsp;';
							}
							?> <?php
							if ( $reservation['comments_general'] ) {
								echo __('general') . ':' . $reservation['comments_general'] ;
								if ( $reservation['comments_internal'] ) {
									echo '<br />';
								}
							} else {
								echo '&nbsp;';
							}
							?> <?php
							if ( $reservation['comments_internal'] ) {
								echo __('internal') . ':' . $reservation['comments_internal'] . '';
							} else {
								echo '&nbsp;';
							}
							?>
							</td>
						</tr>
						<?php $total_persons += $reservation['person_no']; ?>
						<?php endforeach ?>
					</table>
			</td>
			</tr>
			<tr>
				<td valign="top">&nbsp;</td>
				<td valign="top">
					<table cellpadding="0" cellspacing="0">
						<tr>
							<td colspan="2"
								style="border-top-style: solid; border-top-width: 1px; border-color: black"
								align="right" width="50"><?php echo count($reservations) ?> <?php echo __('res') ?>
								/ <strong><?php echo $total_persons ?> <?php echo __('pers') ?>
							</strong>
							</td>

						</tr>
					</table>
				</td>
			</tr>

			<?php endif ?>
			<?php endforeach ?>
			<?php endforeach ?>
			<?php else: ?>
			<tr>
				<td valign="top">&nbsp;</td>
				<td valign="top">
					<table cellpadding="0" cellspacing="0">
						<tr>
							<td
								style="border-top-style: solid; border-top-width: 1px; border-color: black"
								align="right" width="50"><strong>0 / 0</strong></td>
						</tr>
					</table>
				</td>
			</tr>
			<?php endif ?>
			<?php endforeach ?>
		</table>
	</div>
</div>
